<?php

Class Sales_order_out extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
	}

	function index()
	{
		$this->tampil();
	}

	function tampil()
	{
        $noso = $this->uri->segment(4);
        
        $ilc['nobkb']   = $this->mbkb->nobkb();
        $ilc['tanggal'] = date("d-m-Y"); 
        $ilc['soid']    = $noso;
        $ilc['row']     = $this->mso->getsale($noso);
        $ilc['daftar_so'] = $this->mso->getsaledetail($noso );
		$this->load->view('transaksi/vsales_order_out',$ilc);
	}
    
    function proses()
    {
        $prokode = $this->input->get('prokode');
        $nobkb   = $this->input->get('nobkb');

        $ilc['soid'] = $this->input->get('soid');
        $ilc['daftar_batch'] = $this->mbkb->get_batch($prokode);
        $ilc['row'] = $this->mbkb->getproduk($prokode);
        $ilc['nobkb'] = $nobkb;
        $ilc['prokode'] = $prokode;
        $this->load->view('transaksi/vbkb',$ilc);
    }
    
    function simpan()
    {
        $prokode = $this->input->post('prokode');
        $nobkb   = $this->input->post('nobkb');
        $soid    = $this->input->post('soid');
        $pabrik  = $this->input->post('pabrik');
        
        $qty     = $this->input->post('qty');
        $keterangan     = $this->input->post('keterangan');
        $nobatch = $this->input->post('batch');
        
        $stat = $this->mbkb->simpan($nobkb,$soid,$prokode,$qty,$keterangan,$nobatch,$nobatch);
        $this->session->set_flashdata('alert',$stat);
  	    echo "<script>window.opener.document.location.reload(true); window.close()</script>";	
    }	
}